
function GetQueryString(name) {
    var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
    var r = window.location.search.substr(1).match(reg);
    if(r!=null)return  unescape(r[2]); return null;
}
var id=GetQueryString('id');
function NewData(id){
    //console.log(id);
    $.ajax({
        type:"post",
        url:"http://huodong.lingwangyun.cn/News/igetNewsInfo",
        dataType:"JSON",
        data:{id:id},
        success:function(info){
           // console.log(info);
            if(info.code==0){
                //console.log('ajax',id,'数据',info);
                var key=info.data.data[0];
                var up=info.data.up[0],down=info.data.down[0];
               // console.log(up.id,down.id);
			   var title='<p>'+key.title+'</p><div><span>发布于</span><span class="margin-right">'+key.createdate+'</span><span>浏览次数：</span><span>'+key.times+'</span></div>';
                $('.CH-cont>div.cont>.title').html(title);
                $('.CH-cont>div.cont>.ajax').html(key.content);
                if(up.id!=-1){
                    if(down.id!=-1){
						var yema='<div myId="'+up.id+'"><span>上一篇：</span><span>'+up.title+'</span></div><div class="F-right" myId="'+down.id+'"><span>下一篇：</span><span>'+down.title+'</span></div>';
                        $('.CH-cont>div.cont>.button').html(yema);
                    }else{
                        var yema='<div myId="'+up.id+'"><span>上一篇：</span><span>'+up.title+'</span></div><div class="F-right" myId="-1"></div>';
                        $('.CH-cont>div.cont>.button').html(yema);
                    }
                }else{
                    if(down.id!=-1){
                        var yema='<div myId="-1"></div><div class="F-right" myId="'+down.id+'"><span>下一篇：</span><span>'+down.title+'</span></div>';
                        $('.CH-cont>div.cont>.button').html(yema);
                    }else{
                        var yema='<div myId="-1"></div><div class="F-right" myId="-1"></div>';
                        $('.CH-cont>div.cont>.button').html(yema);
                    }
                }
            }
        }
        ,error:function(){
            alert('ajax请求失败');
        }
    })
}
NewData(id);
$('.CH-cont>div>div.button').on('click','div',function(){
    var $this=$(this);
    var NowId=$this.attr('myId');
    //console.log('此时页面',NowId);
    if(NowId!=-1){
        NewData(NowId);
    }
})
